<template>
  <div class="nav-footer fix_iphonex">
    <div
      class="nav-footer-item"
      :class="{item:true,active:item.active == fooTabIndex}"
      v-for="item in footTabs"
      :key="item"
    >
      <img class="icon" alt :src="item.active==fooTabIndex?item.activeIcon:item.defaultIcon" />
      <span>{{item.name}}</span>
      <div class="opacityer" @click.stop="footClick(item)"></div>
    </div>
    <div></div>
  </div>
</template>

<script>
import footer_square from "@/assets/images/menu_aquare_sel.png";
import footer_square_nor from "@/assets/images/menu_aquare_nor.png";
import footer_mine from "@/assets/images/menu_mine_sel.png";
import footer_mine_nor from "@/assets/images/menu_mine_nor.png";

import Vue from "vue";
import mixin from "@/utils/mixin";
import { Toast } from "vant";
Vue.use(Toast);
const footTabs = [
  {
    icon: "footer_square",
    name: "广场",
    toLink: "/infIndex/index",
    active: "infIndex",
    activeIcon: footer_square,
    defaultIcon: footer_square_nor
  },
  {
    icon: "footer_mine",
    name: "我的",
    toLink: "/infIndex/mine",
    active: "infMine",
    activeIcon: footer_mine,
    defaultIcon: footer_mine_nor
  }
];
export default {
  name: 'navFooter',
  mixins: [mixin],
  components: {},
  data () {
    return {
      footTabs,
      fooTabIndex: ""
    };
  },
  mounted () {
    this.fooTabIndex = this.$route.name;
  },
  methods: {
    footClick (item) {
      if (item.active == "infMine") { 
        let sto_uid = window.localStorage.getItem("uniqueIdByInfluencer"); 
        console.log(sto_uid)
        if (!this.isNull(sto_uid)) { 
          this.$http.post("user/getUserInfo", {uniqueId:sto_uid })
            .then(res => {
              if (res.data.completeStatus) {  
                this.$router.replace(item.toLink);
                return false;
              }
              this.$router.push("/infLogin/improveInfo");
              return false;
            });
        } else {
          Toast({
            type: "fail",
            message: "请先登录！",
            onClose: () => { 
              this.$router.replace("/infLogin/login");
            }
          });
        }
      } else {  
        this.$router.replace(item.toLink);
      }
    }
  }
};
</script>
 
<style scoped lang="scss">
.nav-footer {
  display: flex;
  width: 750px;
  height: 98px;
  background: rgba(248, 249, 251, 1);
  justify-content: center;
  align-items: center;
  position: fixed;
  bottom: 0;
  left: 0;
  z-index: 9999;
  transform: translateZ(0);
  .nav-footer-item {
    flex: 1;
    height: 100%;
    font-size: 34px;
    font-family: PingFangSC-Regular;
    font-weight: 400;
    color: rgba(135, 135, 135, 1);
    line-height: 98px;
    text-align: center;
    position: relative;
    .icon {
      width: 43px;
    }
    span {
      margin-left: 16px;
      position: relative;
      top: 3px;
    }
    .opacityer {
      width: 100%;
      height: 100%;
      position: absolute;
      top: 0;
      left: 0;
    }
  }
  .active {
    color: rgba(255, 37, 37, 1);
  }
} 
</style>
